<?php
namespace app\admin\controller;
use think\Controller;
use think\Db;
use think\Md5;
use think\Session;
use think\Request;
use think\Cookie;

class Login extends Controller
{
	public function login()
	{
		return $this->fetch();
	}
	public function doLogin(Request $request)
	{
		$data = $request->param();
		$db = DB::table('user')->where('username',$data['username'])->find();
		if($db){
			$yhpd = md5($data['password']);
			$sjpd = $db['password'];
			if($yhpd==$sjpd){
				if($db['status']==1){
					//写入session
				 session(['adminid'=>$db['id'],'adminusername'=>$data['username'],'adminphoto'=>$db['pic']]);
				  return $this->success('登陆成功','admin/index/index');
				}
			}

		}

	}
}